<?php
/**
 * Created by PhpStorm.
 * User: Cailusen
 * Date: 2018/3/6
 * Time: 11:24
 */

use Biz\service\Sku as sSku;
use Doraemon\pockets\constInterface\AppType;
use Biz\pockets\constInterface\ActivityInfo;

/**
 * @deprecated
 */
class ListAction extends ActionPlugin
{
    const USER_LEVEL = self::LEVEL_NOTHING;

    public function main()
    {

        $appType = $this->appType;
        $activityType = $this->getRequest()->getQuery('activity_type', ActivityInfo::ACTIVITY_TYPE_NORMAL);
        if($appType == AppType::APPTYPE_TUAN_MINIPROGRAM) {
            $activityType = ActivityInfo::ACTIVITY_TYPE_TUAN;
        }
        $version = version_compare($this->appVersion, '4.6.5', '>=');
        if($version) {
            $activityType = ActivityInfo::ACTIVITY_TYPE_ZHUYOUJINTIE;
        }
        $goods_id = $this->getRequest()->getQuery('goods_id');
        if ($activityType == ActivityInfo::ACTIVITY_TYPE_PINTUAN) {
            $info = sSku::skuList($goods_id);
        } else {
            $info = sSku::Sku($goods_id, sSku::FIELDS_GROUP_ALL, ['activity_type' => $activityType, 'not_activity_type' => [ActivityInfo::ACTIVITY_TYPE_PINTUAN]]);
        }
        $this->setSuccess($info);
    }
}
